package com.csun.cmny.provider.service.impl;

import com.csun.cmny.base.dto.LoginAuthDto;
import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.OmcFoodMapper;
import com.csun.cmny.provider.dao.OmcMenuMapper;
import com.csun.cmny.provider.model.domain.OmcMenu;
import com.csun.cmny.provider.model.vo.OmcMenuVo;
import com.csun.cmny.provider.pojo.OmcFood;
import com.csun.cmny.provider.service.OmcFoodService;
import com.csun.cmny.provider.service.OmcMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class OmcFoodServiceImpl extends BaseService<OmcFood> implements OmcFoodService {
    @Resource
    private OmcFoodMapper omcFoodMapper;

    /**
     * 保存或者更新食物信息
     * @param omcFood
     * @param loginAuthDto
     * @return
     */
    @Override
    public int saveOmcFood(OmcFood omcFood, LoginAuthDto loginAuthDto) {
        omcFood.setUpdateInfo(loginAuthDto);
        if(omcFood.isNew()){//保存
            return omcFoodMapper.insertSelective(omcFood);
        }else{//更新
            return  omcFoodMapper.updateByPrimaryKeySelective(omcFood);
        }
    }
}
